const App = {
    // mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            // page: {
            //     PageNumber: 1, //页码
            //     RowAmount: 10,
            //     Condition: window.btoa(unescape(encodeURIComponent("%%,%'"+ getYMDHMSDate('yyyy-MM') +"'%"))),
            // },
            Tabledata: [],
            filterPersonalName: '',
            filterYearMonth: null,
            treeData: [],
        }
    },
    mounted() {

        this.filterYearMonth = new Date();
        this.GetTabledata(this.filterYearMonth, '', '');
        this.Treedata();
    },
    methods: {
        //树的点击筛选事件
        handleNodeClick(data, node) {
            this.GetTabledata(this.filterYearMonth, this.filterPersonalName, data.ProvinceNumber);
        },
        Treedata() {
            const _this = this;
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/clientOperation/getDistrictTree`,
                type: "GET",
                data: {
                    DistrictCode: "232723",
                },
                success: (data) => {
                    this.treeData = data; // 直接使用 this

                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
        },

        getCurrentYearMonth() {
            const now = new Date();
            const year = now.getFullYear();
            const month = String(now.getMonth() + 1).padStart(2, '0');
            return `${year}-${month}`;
        },
        GetTabledata(YearMonth, PersonName, ProvinceNumber) {
            let strwhere = ' where 1=1'
            if (YearMonth) {
                strwhere += " and datalist.ddate like '%" + YearMonth.getFullYear() + "%'";
            }


            if (PersonName) {
                strwhere += " and datalist.Personal_Name like '%" + PersonName + "%'";
            }

            if (ProvinceNumber) {
                strwhere += " and datalist.RR_Village_Number like '%" + ProvinceNumber + "%'";
            }

            //默认当月数据
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                method: "post",
                data: {
                    SQLSerialNumber: "SQL_patrol_CheckIn_SumData", //sql名
                    Condition: "",
                    ExtensionCondition: window.btoa(
                        unescape(
                            encodeURIComponent(strwhere))),
                },
                success: (res) => {
                    this.Tabledata = res;
                    // return ldates;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
            })

        },
        check() {
            // if (this.page.value1) {
            //     this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%")));
            // } else {
            //     this.page.Condition = window.btoa(unescape(encodeURIComponent("%%")));
            // }
            // this.postgetList(this.page)
            this.GetTabledata(this.filterYearMonth, this.filterPersonalName);
        },
        isValidValue(value) {
            return value !== '' && value != null;
        },
        handleCalendar(row) {
            window.location.href = "./rili.html?action=Query&ID_Card_Number=" + row.ID_Card_Number + "&Personal_Name=" + row.Personal_Name;
        }

    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
